package com.aaa.service.tester.impl;


import com.aaa.dao.tester.TesterDao;
import com.aaa.dao.view.ViewsDao;
import com.aaa.entity.tester.Tester;
import com.aaa.entity.ViewsEntity;
import com.aaa.service.tester.LoginTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：肖成杰（1752167034@qq.com）
 * @date ：Created in 2022/9/1 19:16
 * @description：测试者业务层
 * @modified By：
 * @version: 1.0
 */
@Service
public class LoginTestServiceImpl implements LoginTestService {

    @Autowired
    TesterDao testerDao;

    @Autowired
    ViewsDao viewsDao;


    /**
     * @return java.util.List<Map < String, Object>>
     * @create by: 肖成杰
     * @description:
     * @create time: 2022/9/2 14:23
     * @params tester -->包含手机号、姓名、邀请码
     */
    /*@Override
    public List<Map<String, Object>> loginTestQuestion(Tester tester) {

        //根据前端传过来的邀请码查询出对应的数据
        List<ViewsEntity> queryType = viewsDao.queryType(tester.getTestCode());
        //判断是否查询到数据
        if (ObjectUtil.isNotEmpty(queryType)) {
            //计划id
            Integer planId = queryType.get(0).getId();
            //题目类型
            String type = queryType.get(0).getType();
            //将测试计划id传到Tester实现类里面
            tester.setTestPlanId(planId);

            Map<String, Object> map = new HashMap<>();
            List<Map<String, Object>> mapList = new ArrayList<>();
            switch (type) {
                case "fpa":
                    //将数据插入到tbl_tester_fpa表中
                    testerDao.insertFPA(tester);
                    //查询测试人员id
                    List<Integer> list = testerDao.selectFPAId(tester);

                    map.put("testerId", list.get(0));
                    //查询问题表
                    mapList = testerDao.selectQuestionFPA();
                    mapList.add(map);
                    break;
                case "scl":
                    //将数据插入到tbl_tester_scl表中
                    testerDao.insertSCL(tester);
                    //查询测试人员id
                    List<Integer> listScl = testerDao.selectSCLId(tester);
                    map.put("testerId", listScl.get(0));
                    //查询问题表
                    mapList = testerDao.selectQuestionSCL();
                    mapList.add(map);
                    break;
                case "mht":
                    //将数据插入到tbl_tester_mht表中
                    testerDao.insertMHT(tester);
                    //查询测试人员id
                    List<Integer> listMht = testerDao.selectMHTId(tester);
                    map.put("testerId", listMht.get(0));
                    //查询问题表
                    mapList = testerDao.selectQuestionMHT();
                    mapList.add(map);
                    break;
                case "sas":
                    //将数据插入到tbl_tester_sas表中
                    testerDao.insertSAS(tester);
                    //查询测试人员id
                    List<Integer> listSas = testerDao.selectSASId(tester);
                    map.put("testerId", listSas.get(0));
                    //查询问题表
                    mapList = testerDao.selectQuestionSAS();
                    mapList.add(map);
                    break;
                case "sds":
                    //将数据插入到tbl_tester_fpa表中
                    testerDao.insertSDS(tester);
                    //查询测试人员id
                    List<Integer> listSds = testerDao.selectSDSId(tester);
                    map.put("testerId", listSds.get(0));
                    //查询问题表
                    mapList = testerDao.selectQuestionSDS();
                    mapList.add(map);
                    break;
                default:
                    break;
            }
            return mapList;

        }
        return null;
    }*/
    @Override
    public List<ViewsEntity> queryTestCode(Tester tester) {
        return viewsDao.queryType(tester.getTestCode());
    }


    @Override
    public int insertFPA(Tester tester) {
        return testerDao.insertFPA(tester);
    }


    @Override
    public List<Integer> selectFPAId(Tester tester) {
        return testerDao.selectFPAId(tester);
    }

    @Override
    public List<Map<String, Object>> selectQuestionFPA() {
        return testerDao.selectQuestionFPA();
    }


    @Override
    public int insertSCL(Tester tester) {
        return testerDao.insertSCL(tester);
    }


    @Override
    public List<Integer> selectSCLId(Tester tester) {
        return testerDao.selectSCLId(tester);
    }

    @Override
    public List<Map<String, Object>> selectQuestionSCL() {
        return testerDao.selectQuestionSCL();
    }


    @Override
    public int insertSDS(Tester tester) {
        return testerDao.insertSDS(tester);
    }


    @Override
    public List<Integer> selectSDSId(Tester tester) {
        return testerDao.selectSDSId(tester);
    }

    @Override
    public List<Map<String, Object>> selectQuestionSDS() {
        return testerDao.selectQuestionSDS();
    }

    @Override
    public int insertSAS(Tester tester) {
        return testerDao.insertSAS(tester);
    }

    @Override
    public List<Integer> selectSASId(Tester tester) {
        return testerDao.selectSASId(tester);
    }

    @Override
    public List<Map<String, Object>> selectQuestionSAS() {
        return testerDao.selectQuestionSAS();
    }

    @Override
    public int insertMHT(Tester tester) {
        return testerDao.insertMHT(tester);
    }


    @Override
    public List<Integer> selectMHTId(Tester tester) {
        return testerDao.selectMHTId(tester);
    }

    @Override
    public List<Map<String, Object>> selectQuestionMHT() {
        return testerDao.selectQuestionMHT();
    }
}